// pages/homeWelfareCenter/homeWelfareCenter.js
import {reqWelfare} from '../../api/homeWelfareCenter'
Page({
  data: {
    pageNo: 1,
    pageSize: 8,
    listData: [],
    loading: 0
  },
  onLoad(options) {
    this.getData();
  },
  // 返回
  goBack() {
    wx.navigateBack();
  },
  // 触底事件
  onReachBottom() {
		let page = this.data.pageNo+1;
		if(this.data.loading==2){
			return;
		}
		this.setData({pageNo:page,loading:1})
		this.getData();
  },
  // 获取数据
  async getData(){
		let {pageNo,pageSize} = this.data;
    let res = await reqWelfare({pageNo,pageSize});
    // console.log(res);
		if(res.statusCode == 200){
			if(res.data.length==0){
				this.setData({loading:2});
			}else {
				this.setData({loading:0});
      }
      this.setData({listData:[...this.data.listData,...res.data]});
      // console.log(this.data.listData);
		}
	},
})